import React, { Component } from 'react'
import style from "./list_main.module.css"
import axios from 'axios'
import ListMain from '../../../components/shoplist/list_main_List'
import initscroll from '../../../components/betterscroll'

export class list_main extends Component {
    state={
        shoplist:[],
        iTime:''
    }
    componentDidMount(){
        this.state.shoplist = this.props.shoplist
       
        this.setState({})
    }
    getlist=()=>{
        axios.get('/shop/getall').then(res=>{
            console.log(res)
            res.data.lists.forEach(item=>{
                this.state.shoplist.push(item)
            })
            
            this.setState({
                
            })
            console.log(this.state.shoplist)
        })
    }
    getList=()=>{
        axios.get('/shop/getall').then(res=>{
            console.log(res)
            res.data.lists.forEach(item=>{
                this.state.shoplist.push(item)
            })
            
            this.setState({
                
            })
            console.log(this.state.shoplist)
        })
    }
    aaa=()=>{
            initscroll('.better',this.getList,this.getlist)
    }
    render() {
        let {shoplist} = this.state
        return (
            <div  style={{height:'10rem', overflow:'auto'}} onScroll={this.aaa} className='better'>
                <ul className={style.list_main}>
                    {
                        <ListMain shoplist={shoplist}></ListMain>
                    }
                    <p className={style.foot}>没有更多内容</p>
                </ul>
            </div>
        )
    }
}
export default list_main
